#include <algorithm>
#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>
using ll = int64_t;

#define gop(i,j)(std::get<j>(ops[i]))

int main(){
    ll m;
    std::cin>>m;
    std::vector<ll> arr;
    std::vector<std::tuple<ll,ll,ll>> ops(m+1);
    arr.reserve(m);
    for(ll i=1;i<=m;i++){
        std::cin>>gop(i,0);
        if(gop(i,0)==1){
            std::cin>>gop(i,1)>>gop(i,2);
            arr.push_back(gop(i,1));
        }else {
            std::cin>>gop(i,1)>>gop(i,2);
            arr.push_back(gop(i,1));
            arr.push_back(gop(i,2));
        }
    }
    std::sort(arr.begin(),arr.end());
    arr.erase(std::unique(arr.begin(),arr.end()),arr.end());
    for(ll i=0;i<arr.size();i++)std::cout<<arr[i]<<",";
    std::cout<<'\n';
}